-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New+ Support for variables in template filenames (35287) #37074
base: main
Are you sure you want to change the base?
New+ Support for variables in template filenames (35287) #37074
Conversation
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-template-filename
…upport-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…upport-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
This comment has been minimized.
This comment has been minimized.
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…upport-for-variables-in-templates
…ables-in-templates
Has conflicts |
…upport-for-variables-in-templates
Recent conflicts with GPO settings are now resolved again |
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -289,7 +297,6 @@ If you don't configure this policy, the user takes control over the setting and | |||
<string id="MwbPolicyDefinedIpMappingRules">Predefined IP Address mapping rules</string> | |||
<string id="NewPlusHideTemplateFilenameExtension">Hide template filename extension</string> | |||
<string id="AllowDiagnosticData">Allow sending diagnostic data</string> | |||
<string id="ConfigureRunAtStartup">Configure the run at startup setting</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this string removed? I suspect a bad merge.
@@ -18,6 +18,7 @@ public NewPlusProperties() | |||
HideFileExtension = new BoolProperty(true); | |||
HideStartingDigits = new BoolProperty(true); | |||
TemplateLocation = new StringProperty(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "NewPlus", "Templates")); | |||
ReplaceVariables = new BoolProperty(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps default should be false? Since this new feature might break existing behavior in an unexpected way for some users right after updating PowerToys.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cgaarden , Thank you for opening the PR.
I think the code looks good and I like the approach. I tried to use the docs and not everything worked for me:
"$YYYY-$MM-%DD, $hh $mm $ss - $PARENT_FOLDER_NAME by %USERNAME%"
I tried this and saw that there's a error in %DD
instead of $DD
, but still couldn't get $PARENT_FOLDER_NAME to work for me.
I left some smaller comments a bit before writing this review. Thank you :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant request change instead of approve, sorry 😅
Summary of the Pull Request
Added support for variables in template filenames
Variables supported includes
$YYYY
,$YY
,$MM
,$DD
, - using the same syntax and implementation as in PowerRename$PARENT_FOLDER_NAME
- will replace variable with the name of the parent folder%environment-variable%
- will replace variable with the value of the corresponding environment variableExample:
Template filename:
$YYYY-$MM-%DD, $hh - $PARENT_FOLDER_NAME by %USERNAME%
Filename on create becomes:
2025-01-25, 02 - PowerShell project by cgaarden
PR Checklist
PowerToys New+ variable support in template filenames -- documentation related updates MicrosoftDocs/windows-dev-docs#5285
Detailed Description of the Pull Request / Additional comments
SHFileOperation API related
Still using SHFileOperation API - may change this in a future PR as the current implementation requires iterating through files multiple times (not really that impactful unless a template folder contains 100s+ of files/subfolders
Fixed an issue on ARM64 when depending on SHFileOperation to provide filename remapping
Minor refactoring
To help with support the variable support
Minor exception handling logic
To help get information on where New+ menu isn't being displayed
Validation Steps Performed
Example template folder + corresponding context menu
Example of project including subitems
New+ settings
(debug)

New+ related GPO policies